<?php
include_once("./_common.php");
include_once("./adm_head.php");

$sql = "SELECT *
		  FROM visit_record
		 WHERE id = '$id'";
$rst = sql_query($sql);
$view = mysql_fetch_assoc($rst);

$store_num = $view['vi_area'];
$this_year = date("Y");
$sql2 = "SELECT y{$this_year}
		   FROM month_avg
		  WHERE store_num = '$store_num'";
$rst2 = sql_query($sql2);
$view2 = mysql_fetch_assoc($rst2);
$this_str = $view2["y".$this_year];
$vi_month = explode(",", $this_str);
?>

<style>
	div.wrap {width:100%;text-align:center;margin:0 auto;font-family:"돋음, Tahoma, 굴림";font-size:9pt;background-color:#fff}
	div.title_wrap {margin:5px 0px 10px 0px;}
	div.title_wrap h3 {width:160px;text-align:center;margin:0 auto; font-family:"나눔고딕";color:#fff;xborder:2px solid #5970a4; padding:7px 0px 7px 0px; background-color:#5970a4;}

	div.table1 {}
	div.table1 p {text-align:left;margin:5px 5px 0px 5px;}
	table.info1 {border:2px solid #5970a4;width:100%;}
	table.info1 tr {height:40px;border-top:1px solid #d9d9d9;}
	table.info1 th {border-top:1px solid #fff;background-color:#5970a4;text-align:left; padding-left:5px;height:39px; color:#fff;}
	table.info1 td {border-top:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;text-align:left;padding-left:10px;}
	
	div.table2 {margin-top:5px;}
	div.table2 p {text-align:right}
	table.info2 {border:2px solid #5970a4;width:100%;}
	table.info2 tr {height:40px;border-top:1px solid #d9d9d9;}
	table.info2 th {border-top:1px solid #fff;background-color:#5970a4;text-align:left; padding-left:5px;height:39px; color:#fff;}
	table.info2 td {border-top:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;text-align:left;padding-left:10px;}
	.txtwd {width:95%}
	.tareawd {width:96%}

	div.table3 {margin-top:5px;}
	div.table3 p {text-align:right}
	table.info3 {border:2px solid #5970a4;width:100%;}
	table.info3 tr {height:50px;border-top:1px solid #d9d9d9;}
	table.info3 th {border-top:1px solid #fff;background-color:#5970a4;text-align:left; padding-left:5px;height:39px; color:#fff;}
	table.info3 td {border-top:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;text-align:left;padding-left:10px;}
</style>

<div class="wrap">
	<div class="title_wrap">
		<h3>방 문 일 지</h3>
	</div>
	<div class="table1">
		<p>No. : <?php echo $view['vi_no']?></p>
		<table class="info1" border=0 cellspacing=0 cellpadding=0>
			<colgroup>
			<col width="118px" />
			<col width="" />
			</colgroup>
			<tr style="border-top:none;">
				<th style="border-top:none;">방문일자</th>
				<td><?php echo $view['vi_date']?></td>
			</tr>
			<tr>
				<th>구분</th>
				<td><?php echo $view['vi_flag']?></td>
			</tr>
			<tr>
				<th>방문자</th>
				<td><?php echo $view['vi_name1']?></td>
			</tr>
			<tr>
				<th>방문시간</th>
				<td><?php echo $view['vi_time']?></td>
			</tr>
		</table>
	</div>
	<div class="table2">
		<table class="info2" border=0 cellspacing=0 cellpadding=0>
			<colgroup>
			<col width="118px" />
			<col width="" />
			</colgroup>
			<tr>
				<th>점명</th>
				<td><?php echo $view['vi_store']?>
			</td>
			</tr>
			<tr>
				<th>점주명</th>
				<td><?php echo $view['vi_name2']?></td>
			</tr>
			<tr>
				<th>직원수</th>
				<td><?php echo $view['vi_count']?></td>
			</tr>
			<tr>
				<th>평균<br/>고객수</th>
				<td><?php echo $view['vi_avg']?></td>
			</tr>
			<tr>
				<th>금일<br/>매출현황</th>
				<td><?php echo $view['vi_sales']?></td>
			</tr>
			<tr>
				<th>월 평균 매출</th>
				<td>
					<?php if($vi_month['0'] != "") { ?>
						1월 <?php echo $vi_month['0']?><br />
					<? } ?>
					<?php if($vi_month['1'] != "") { ?>
						2월 <?php echo $vi_month['1']?><br />
					<? } ?>
					<?php if($vi_month['2'] != "") { ?>
						3월 <?php echo $vi_month['2']?><br />
					<? } ?>
					<?php if($vi_month['3'] != "") { ?>
						4월 <?php echo $vi_month['3']?><br />
					<? } ?>
					<?php if($vi_month['4'] != "") { ?>
						5월 <?php echo $vi_month['4']?><br />
					<? } ?>
					<?php if($vi_month['5'] != "") { ?>
						6월 <?php echo $vi_month['5']?><br />
					<? } ?>
					<?php if($vi_month['6'] != "") { ?>
						7월 <?php echo $vi_month['6']?><br />
					<? } ?>
					<?php if($vi_month['7'] != "") { ?>
						8월 <?php echo $vi_month['7']?><br />
					<? } ?>
					<?php if($vi_month['8'] != "") { ?>
						9월 <?php echo $vi_month['8']?><br />
					<? } ?>
					<?php if($vi_month['9'] != "") { ?>
						10월 <?php echo $vi_month['9']?><br />
					<? } ?>
					<?php if($vi_month['10'] != "") { ?>
						11월 <?php echo $vi_month['10']?><br />
					<? } ?>
					<?php if($vi_month['11'] != "") { ?>
						12월 <?php echo $vi_month['11']?>
					<? } ?>
				</td>
			</tr>
			<tr>
				<th>이벤트현황</th>
				<td><?php echo $view['vi_event']?></td>
			</tr>
			<tr>
				<th>홀<br/>유지 관리상태</th>
				<td><?php if($view['vi_hall'] == "0") { echo "양호"; } else { echo "불량";}?></td>
			</tr>
			<tr>
				<th>간판<br/>유지 관리상태</th>
				<td><?php if($view['vi_sign'] == "0") { echo "양호"; } else { echo "불량";}?></td>
			</tr>
			<tr>
				<th>쇼 윈도우 및 사인물<br/>유지 관리상태</th>
				<td><?php if($view['vi_show'] == "0") { echo "양호"; } else { echo "불량";}?></td>
			</tr>
			<tr>
				<th>카운터 및 주방<br/>유지 관리상태</th>
				<td><?php if($view['vi_cash'] == "0") { echo "양호"; } else { echo "불량";}?></td>
			</tr>
			<tr>
				<th>유니폼<br/>착용 유무</th>
				<td><?php if($view['vi_uni'] == "0") { echo "유"; } else { echo "무";}?></td>
			</tr>
			<tr>
				<th colspan="2" style="text-align:center;">내용</th>
			</tr>
			<tr>
				<td colspan="2">
					<?php echo nl2br($view['vi_content'])?>
				</td>
			</tr>
			<tr>
				<th colspan="2" style="text-align:center;">첨부파일</th>
			</tr>
			<tr>
				<td colspan="2">
					<?php if($view['vi_file0'] != "")
					{
						if(substr($view['j_data'],0,22) == "../../data/file/visit/")
						{
						?>
							<img src="<?php echo $view['vi_file0']?>" style="width:95%" />
						<?
						}
						else
						{
						?>
							<img src="<?php echo G5_URL."/img_sign/".$view['vi_file0']?>" style="width:95%" />
						<?
						}
					}
					?>
					<?php if ($view['vi_file1'] != "")
					{
						if(substr($view['j_data'],0,22) == "../../data/file/visit/")
						{
						?>
							<img src="<?php echo $view['vi_file1']?>" style="width:95%" />
						<?
						}
						else
						{
						?>
							<img src="<?php echo G5_URL."/img_sign/".$view['vi_file1']?>" style="width:95%" />
						<?
						}
					}
					?>
				</td>
			</tr>
		</table>
	</div>
	<div class="table3">
		<table class="info3" border=0 cellspacing=0 cellpadding=0>
			<tr>
				<td style="position:relative;height:55px;text-align:right;">
					<?
					if($view['vi_confirm'] == "")
					{
					?>
					<span style="display:block;position:absolute;bottom:5px;right:5px"><font style="color:#dddddd;">(인) 또는 서명</font></span>
					<?
					}
					else
					{
					?>
					<span style="display:block;position:absolute;bottom:5px;right:5px;color:#dddddd;">점주명: <font style="font-size:16px;color:#000000;"><?php echo $view['vi_confirm']?></font></span>
					<?
					}

					if(substr($view['j_data'],0,4) == "data")
					{
					?>
						<img src="<?php echo $view['j_data']?>" style="width:100%" />
					<?
					}
					else
					{
					?>
						<img src="<?php echo G5_URL."/img_sign/".$view['j_data']?>" style="width:100%;" />
					<?
					}
					?>
				</td>
			</tr>
		</table>
	</div>
	<?
	if ($my_lv == "4")
	{
	?>
	<div style="height:50px;margin:10px 0px 2px 0px; padding-bottom:10px;">
		<div style="float:left;height:100%;width:100%;"><input type="button" value="수정" class="bt_mo" style="height:100%;width:100%;"/>
		<!--<div style="float:left;height:100%;width:50%;"><input type="button" value="수정" class="bt_mo" style="height:100%;width:100%;"/></div>-->
		<!--<div style="float:left;height:100%;width:50%;"><input type="button" value="삭제" class="bt_de" style="height:100%;width:100%;"/></div>-->
	</div>
	<?
	}
	?>
</div>

<script>
$(".bt_mo").click(function() {
	location.href = "<?php echo G5_URL?>/mobile/android/visit_a.php?w=u&branch=<?php echo $view['vi_area']?>&id=<?php echo $view['id']?>";
});
//$(".bt_de").click(function() {
//	location.replace("<?php echo $g5['path']?>/m/android/visit_update_a.php?w=d&branch=<?php echo $view['vi_area']?>&id=<?php echo $view['id']?>");
//});
</script>
